<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>Windows Interface Reference: Globals structure</title>
</head>

<body>

<h1>Globals </h1>

<p>The Globals structure contains various functions to operate on handles, functions to
obtain handles to the Poly/ML application and window and a function to get error
information. </p>

<pre>structure Globals :
  sig
    type 'a <a href="#Handles">HANDLE</a>
    type HINSTANCE
    type HWND
    val <a
href="#Handles">hNull</a> : 'a HANDLE
    val <a href="#Handles">handleOfInt</a> : int -&gt; 'a HANDLE
    val <a
href="#Handles">intOfHandle</a> : 'a HANDLE -&gt; int
    val <a href="#Handles">isHNull</a> : 'a HANDLE -&gt; bool

    val <a
href="#ApplicationInstance">ApplicationInstance</a> : unit -&gt; HINSTANCE
    val <a
href="#GetLastError">GetLastError</a> : unit -&gt; OS.syserror
    val <a
href="#MainWindow">MainWindow</a> : unit -&gt; HWND
  end</pre>

<p><tt><a name="Handles"></a>type 'a HANDLE<br>
hNull : 'a HANDLE<br>
handleOfInt(i): 'a HANDLE<br>
intOfHandle(h): int<br>
isHNull(h): bool</tt><br>
<strong>ML Extension:</strong> All handles, such as HWND and HBITMAP, are instances of the
'a HANDLE type. Generally the Windows functions which can take NULL as a valid argument or
return NULL as a valid result take option types.&nbsp; Occasionally it may be necessary to
pass NULL in other circumstances in which case hNull can be used in ML.&nbsp; There are
also a few occasions where a handle has to be cast to or from int.&nbsp; handleOfInt and
intOfHandle can be used for this.</p>

<p><tt><a name="ApplicationInstance">ApplicationInstance</a>(): HINSTANCE</tt><br>
<strong>ML Extension: </strong>Returns the application instance handle passed in to the
WinMain function when Poly/ML was started.</p>

<p><tt><a name="MainWindow">MainWindow</a>(): HWND</tt><br>
<strong>ML Extension: </strong>Returns the handle to the Poly/ML window.</p>

<p><tt><a name="GetLastError">GetLastErro</a>r(): OS.syserror</tt><br>
Returns the error code for the last function call.&nbsp; Generally when a function fails
an exception is raised including the last error as part of the exception packet.</p>
</body>
</html>
